package com.gosuncn.zfysdk.demo.base;

import android.os.Bundle;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import androidx.databinding.ViewDataBinding;
import androidx.navigation.NavController;
import androidx.navigation.NavDestination;
import androidx.navigation.fragment.NavHostFragment;

import com.afollestad.materialdialogs.MaterialDialog;
import com.gosuncn.zfysdk.demo.R;
import com.gosuncn.zfysdk.demo.ui.MainFragment;
import com.gosuncn.zfysdk.demo.utils.MaterialDialogUtils;
import com.wzq.mvvmsmart.base.BaseFragmentMVVM;
import com.wzq.mvvmsmart.utils.KLog;

public abstract class BaseFragment<V extends ViewDataBinding, VM extends BaseViewModel> extends BaseFragmentMVVM<V, VM> {
    public final String TAG = getClass().getSimpleName();
    private MaterialDialog dialog;

    public void showLoading(String title) {
        if (dialog != null) {
            dialog = dialog.getBuilder().title(title).build();
            dialog.show();
        } else {
            MaterialDialog.Builder builder = MaterialDialogUtils.showIndeterminateProgressDialog(getActivity(), title, true);
            dialog = builder.show();
        }
    }

    public void dismissLoading() {
        if (dialog != null && dialog.isShowing()) {
            dialog.dismiss();
        }
    }

    @Override
    public void initToolbar() {
        super.initToolbar();
/*        Toolbar toolbar = (Toolbar)((AppCompatActivity) getActivity()).getWindow().getDecorView().findViewById(R.id.toolbar);
        if(toolbar != null) {
            ((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
        }*/
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
    }
}
